from .Widget import *
from .Label import *
from .ListBlock import *
from .Frame import *
from .Image import *

import starfield

class EntityInfo(Widget):
	"""Widget for displaying blocks of text"""
	
	def __init__(self, parent, name, text="", font=None, pt_size=30, aspect=None,
					size=[1, 1], pos=[0, 0], sub_theme='', options=BGUI_DEFAULT):
		
		Widget.__init__(self, parent, name, aspect, size, pos, sub_theme, options)
		
		self._font = font
		self._pt_size = pt_size

		self._lines = []
		
		self.text = text
		
		#create the widget structure
		self.box = Frame( self, "info", size=[1,1], pos=[0,0], aspect=0.5,
										 sub_theme="Dark", options= BGUI_DEFAULT )
		self.box.info = ListBlock( self.box, "info_text", "Nothing Selected", pt_size=15,
									pos=[.1, .1], size=[.9,.8] )
									
		self.box.icon = Image( self.box, "icon", "images/icon_ship.jpg",
									pos=[.1, .9], size=[.1,.1], aspect=1, options= BGUI_DEFAULT | BGUI_CENTERX)
		self.box.icon.visible = False
		
	def select(self, object):
		
		
			
		if object.role == "star":
			info = ["STAR: "+str(object.id), object.name]
			self.box.info.text = info
			
			self.box.icon.update_image("images/icon_star.jpg")
			self.box.icon.visible = True
		
		if object.role == "ship":
			info = ["SHIP: "+str(object.id), object.name]
			self.box.info.text = info
			
			self.box.icon.update_image("images/icon_ship.jpg")
			self.box.icon.visible = True
	